package org.massi.imslp.query;


import java.util.List;


/**
 * Business logic for query and fetch actions to the IMSLP wiki. The query method allows to return a
 * list of pages that then can be fetched by the fetch method. It's possible to set user credentials
 * to authenticate against the wiki
 */
public interface IImslpQuery
{

	/**
	 * perform a query on the IMSLP wiki, using the provided parameters. Parameters may include
	 * composer name, opus number, work title. Returns a list of page titles. page title can then
	 * used to fetch the entire page using the {@link #fetch(String)} method
	 * 
	 * @param params query parameters
	 * @return list of page titles. If no page is found an empty list (not null) is returned
	 * @throws WikiException if something goes wrong
	 */
	List<String> query(IQueryParameters params) throws WikiException;


	/**
	 * Set credentials to access the wiki
	 * 
	 * @param credentials
	 */
	void setCredentials(ICredentials credentials);


	/**
	 * Fetch a wiki page using the title and return the work information
	 * 
	 * @param pageName page title: must not be null
	 * @return the piece information or null if the page doesn't exist.
	 * @throws WikiException if something goes wrong
	 */
	IComposerWork fetch(String pageName) throws WikiException;

}
